Skip to content

Fix: don't respond to mouse drag events that started outside of our nodes window - #238

Closed
JulesFouchy wants to merge 1 commit into
thedmd:masterfrom
Coollab-Art:drag
Closed

JulesFouchy wants to merge 1 commit into
thedmd:masterfrom
Coollab-Art:drag

Conversation

@JulesFouchy

Copy link
Copy Markdown
Contributor

When you start dragging the mouse in a window not related to the nodes, and then hover the nodes window while dragging, the nodes view starts panning:

Animation1

This PR fixes it and only allows drag events that started in the nodes window to affect the nodes view:

Animation2

thedmd added a commit that referenced this pull request Oct 14, 2026
…238)

A right-drag that started in another window panned the editor as soon as
the mouse entered it, since a pan only needed the button dragging and the
editor focused and hovered. A pan now also needs the press to have made
the editor's background or one of its objects the active item.

Co-authored-by: Jules Fouchy <jules.fouchy@ntymail.com>
@thedmd

thedmd commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Thank you @JulesFouchy! I reproduced it, and fixed it a bit differently: a pan now needs the press to have made the editor's background or one of its objects the active item, so a drag that started elsewhere never pans. It's in v0.9.4 as 4e2a6a3, with you as co-author.

Closing.

@thedmd thedmd closed this Oct 14, 2026
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 15, 2026
…tton

Since the fix of thedmd#238, a pan needs the press to make the background or an object active.
A press on a widget of a node (a button, which uses the left mouse button) made neither: the view did not pan.

The background now takes a press of the navigate button inside the editor that no item owns (SetKeyOwner(), until release):
- a drag from such a widget pans;
- a widget that uses the navigate button owns it, and keeps it;
- a drag pressed outside the editor still does not pan (thedmd#238).

Needs Dear ImGui 1.90.7 (ImGuiKeyOwner_NoOwner). With an older one, nothing changes.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 15, 2026
- from the background, and from a button of a node: the view pans;
- from a widget that uses the navigate button: it keeps the button, the view does not pan;
- from outside the editor: no pan when the drag enters it (thedmd#238).
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
…tton

Since the fix of thedmd#238, a pan needs the press to make the background or an object active.
A press on a widget of a node (a button, which uses the left mouse button) made neither: the view did not pan.

Now a press of the navigate button inside the editor that no item owns is remembered:
- once the mouse drags, the background takes the button until its release (SetKeyOwner()), and the view pans;
- a click stays a click: the context menus of the widget and of its node open, as before;
- a widget that uses the navigate button owns it, and keeps it;
- the release that ends a pan is locked for its frame: no context menu opens under the mouse;
- a drag pressed outside the editor still does not pan (thedmd#238).

Needs Dear ImGui 1.90.7 (ImGuiKeyOwner_NoOwner). With an older one, nothing changes.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
- from the background, and from a button of a node: the view pans;
- from a widget that uses the navigate button: it keeps the button, no pan;
- from outside the editor: no pan (thedmd#238);
- a right click on a button of a node: its context menu and the node's, as before;
- a pan that ends on the button it started from: no context menu.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
…tton

Since the fix of thedmd#238, a pan needs the press to make the background or an object active.
A press on a widget of a node (a button, which uses the left mouse button) made neither: the view did not pan.

Now a press of the navigate button inside the editor that no item owns is remembered:
- once the mouse drags, the background takes the button until its release (SetKeyOwner()), and the view pans;
- a click stays a click: the context menus of the widget and of its node open, as before;
- a widget that uses the navigate button owns it, and keeps it;
- the release that ends a pan is locked for its frame: no context menu opens under the mouse;
- a drag pressed outside the editor still does not pan (thedmd#238).

Needs Dear ImGui 1.90.7 (ImGuiKeyOwner_NoOwner). With an older one, nothing changes.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
- from the background, and from a button of a node: the view pans;
- from a widget that uses the navigate button: it keeps the button, no pan;
- from outside the editor: no pan (thedmd#238);
- a right click on a button of a node: its context menu and the node's, as before;
- a pan that ends on the button it started from: no context menu.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
…tton

Since the fix of thedmd#238, a pan needs the press to make the background or an object active.
A press on a widget of a node (a button, which uses the left mouse button) made neither: the view did not pan.

Now a press of the navigate button inside the editor that no item owns is remembered:
- once the mouse drags, the background takes the button until its release (SetKeyOwner()), and the view pans;
- a click stays a click: the context menus of the widget and of its node open, as before;
- a widget that uses the navigate button owns it, and keeps it;
- the release that ends a pan is locked for its frame: no context menu opens under the mouse;
- a drag pressed outside the editor still does not pan (thedmd#238).

Needs Dear ImGui 1.89 (input ownership). With an older one, nothing changes.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
- from the background, and from a button of a node: the view pans;
- from a widget that uses the navigate button: it keeps the button, no pan;
- from outside the editor: no pan (thedmd#238);
- a right click on a button of a node: its context menu and the node's, as before;
- a pan that ends on the button it started from: no context menu.

The pan from a button, and the end of a pan, need the fix: skipped before Dear ImGui 1.89.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
…tton

Since the fix of thedmd#238, a pan needs the press to make the background or an object active.
A press on a widget of a node (a button, which uses the left mouse button) made neither: the view did not pan.

Now a press of the navigate button inside the editor that no item owns is remembered:
- once the mouse drags, the background takes the button until its release (SetKeyOwner()), and the view pans;
- a click stays a click: the context menus of the widget and of its node open, as before;
- a widget that uses the navigate button owns it, and keeps it;
- the release that ends a pan is locked for its frame: no context menu opens under the mouse;
- a drag pressed outside the editor still does not pan (thedmd#238).

Needs Dear ImGui 1.89 (input ownership). With an older one, nothing changes.
pthom added a commit to pthom/imgui-node-editor that referenced this pull request Oct 16, 2026
- from the background, and from a button of a node: the view pans;
- from a widget that uses the navigate button: it keeps the button, no pan;
- from outside the editor: no pan (thedmd#238);
- a right click on a button of a node: its context menu and the node's, as before;
- a pan that ends on the button it started from: no context menu.

The pan from a button, and the end of a pan, need the fix: skipped before Dear ImGui 1.89.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants